package com.wutianyi.module.commons.config;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author hanjiewu
 * 
 */
public enum ConfigTypeEnum implements Serializable {
	
	COMPANY_STANDARD_PROPERTIES(1);
	
	private static Map<Integer, ConfigTypeEnum> maps = new HashMap<Integer, ConfigTypeEnum>();
	
	static {
		for (ConfigTypeEnum type : ConfigTypeEnum.values()) {
			maps.put(type.getType(), type);
		}
	}
	
	private int type;
	
	private ConfigTypeEnum(int type) {
		this.type = type;
	}
	
	public int getType() {
		return type;
	}
	
	public static ConfigTypeEnum getConfigType(int type) {
		return maps.get(type);
	}
	
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		oos.writeObject(ConfigTypeEnum.COMPANY_STANDARD_PROPERTIES);
		
		ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
		ObjectInputStream ois = new ObjectInputStream(bais);
		
		ConfigTypeEnum configTypeEnum = (ConfigTypeEnum) ois.readObject();
		
		System.out.println(configTypeEnum.getType());
	}
}
